package com.gene.service.impl;

import com.gene.mapper.UserDetailsMapper;
import com.gene.pojo.UserDetails;
import com.gene.pojo.UserDetailsExample;
import com.gene.service.IUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserDetailsServiceImpl implements IUserDetailsService {
    @Autowired
    private UserDetailsMapper userDetailsMapper;


    @Override
    public List<UserDetails> query(UserDetails userDetails) {
        UserDetailsExample example=new UserDetailsExample();
        UserDetailsExample.Criteria criteria = example.createCriteria();
        criteria.andUserIdEqualTo(userDetails.getUserId());
        List<UserDetails> list = userDetailsMapper.selectByExample(example);
        return list;
    }

    @Override
    public boolean add(UserDetails userDetails) {
        int a=userDetailsMapper.insert(userDetails);
        if(a==1){
            return true;
        }
        return false;
    }

    @Override
    public boolean edit(UserDetails userDetails) {
        int a=userDetailsMapper.updateByPrimaryKeySelective(userDetails);
        if(a==1){
            return true;
        }
        return false;
    }

    @Override
    public boolean delete(UserDetails userDetails) {
        int a=userDetailsMapper.deleteByPrimaryKey(userDetails.getDetailsId());
        if(a==1){
            return true;
        }
        return false;
    }
}
